﻿function ShowArray(resultArray) {
    //生成表格及其内容
    var div = $get("divShowResult");
    var table = document.createElement("table");
    table.border = 1;
    for (var i = 1; i < resultArray.length; i++) {
        var row = table.insertRow();
        for (var j = 0; j < resultArray[i].length; j++) {
            var cell = row.insertCell();
            cell.innerText = resultArray[i][j];
            cell.width = resultArray[0][j];
        }
    }
    div.innerText = "";
    div.appendChild(table);
    //确保翻页时行间颜色保持不变
    var no = null;
    if (globals.controlIdentities.IsFirst) {
        no = Math.ceil(Math.random() * 10);
        no = no == 10 ? 5 : no;
        globals.controlIdentities.RandomNum = no;
    }
    else {
        no = globals.controlIdentities.RandomNum == null ? 5 : globals.controlIdentities.RandomNum;
    }
    //设置固定颜色，如要实现动态效果，去掉下面一行即可
    no = 2;
    //设置字段名的颜色
    table.rows(0).className = "ta" + no;
    
    //设置行间颜色间隔
    for (i = 1; i < table.rows.length; i++) {
        (i % 2 == 0) ? (table.rows(i).className = "tc" + no) : (table.rows(i).className = "tb" + no);
    }
}

function rTrim(str) {
    var iLength;

    iLength = str.length;
    if (str.charAt(iLength - 1) == " ") {
        //如果字串右边第一个字符为空格 
        str = str.slice(0, iLength - 1); //将空格从字串中去掉 
        str = rTrim(str); //递归调用 
    }
    return str;
}

function lTrim(str) {
    if (str.charAt(0) == " ") {
        //如果字串左边第一个字符为空格 
        str = str.slice(1); //将空格从字串中去掉 
        str = lTrim(str); //递归调用 
    }
    return str;
}
